const cloud = require('wx-server-sdk');
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV });

exports.main = async (event) => {
  const db = cloud.database();
  const { courseId } = event;

  try {
    const result = await db.collection('course').doc(courseId).get();

    return {
      result,
      message: '查询成功',
    };
  } catch (err) {
    return {
      code: -1,
      message: '查询失败',
    };
  }
};
